// createRouter 创建router实例
// createWebHistroy  创建hostory模式路由对象的
// createWebHashHistory 创建hash模式路由对象
import { createRouter, createWebHashHistory } from 'vue-router'
import Layout from '@/views/Layout' // 首页
import Login from '@/views/Login' // 登录页
import Home from '@/views/Home'
import Category from '@/views/Category' // 一级分类
import SubCategory from '@/views/subCategory' // 二级分类
import PlayGround from '@/views/playground'
import Good from '@/views/Good' // 商品详情
import LoginCallBack from '@/views/Login/LoginCallback.vue' // 第三方登录回跳组件
import Cart from '@/views/Cart' // 购物车
import SettleMent from '@/views/Settlement'
// import Checkout from '@/views/Checkout' // 填写订单
import Pay from '@/views/Pay' // 进行支付
import Callback from '@/views/Pay/CallBack'

const routes = [
  { // 登录页
    path: '/login',
    name: 'Login',
    component: Login
  },
  {
    path: '/login/callback',
    name: 'logincallback',
    component: LoginCallBack
  },
  { // 首页
    path: '/',
    name: 'Layout',
    component: Layout,
    children: [
      { // 二级路由首页
        path: '/',
        component: Home
      },
      { // 一级分类
        path: '/category/:id',
        name: 'Category',
        component: Category
      },
      {
        path: '/subCategory/:id',
        component: SubCategory
      },
      {
        path: '/good/:id',
        component: Good
      },
      {
        path: '/cart',
        component: Cart
      },
      {
        path: '/settlement',
        component: SettleMent
      },
      {
        path: '/pay',
        component: Pay
      },
      {
        path: '/pay/callback',
        component: Callback
      }
    ]
  },
  { // 测试广场
    path: '/play',
    component: PlayGround
  }

  // {
  //   path: '/about',
  //   name: 'About',
  //   // route level code-splitting
  //   // this generates a separate chunk (about.[hash].js) for this route
  //   // which is lazy-loaded when the route is visited.
  //   component: () => import(/* webpackChunkName: "about" */ '../views/About.vue')
  // }
]
// 实例的生成
const router = createRouter({
  history: createWebHashHistory(process.env.BASE_URL),
  routes
})

export default router
